// 订单模型
const { Orders } = require('../../../models/order');
// 商品模型
const { Goods } = require('../../../models/good');
// 统一数据返回类
const { DataReturn } = require('../../../common/returnclass');

module.exports = async (req, res) => {
	let { _id, order_goods } = req.fields;
	console.log(req.fields);
	let { goods_number } = await Goods.findOne({_id: order_goods });
	
	Orders.deleteOne({_id})
	.then(async()=>{
		return await Goods.updateOne({goods_number:goods_number + 1});
	})
	.then(()=>{
		DataReturn.getData(res,200,[],'取消成功')
	}).catch(()=>{
		DataReturn.getData(res,400,[],'取消失败')
	})


}